﻿<UserControl x:Class="Workbench.Presentation.WordListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:view="clr-namespace:Workbench.Presentation"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="700" DataContextChanged="UserControl_DataContextChanged">
    <UserControl.Resources>
        <view:EnumToBoolConverter x:Key="enumConverter" />
        <view:InverseBooleanConverter x:Key="InverseBooleanConverter" />
    </UserControl.Resources>
    <DockPanel>
        <Border MinWidth="250" BorderThickness="0.7 0 0 0" Padding="5 0" DockPanel.Dock="Left">
            <StackPanel>
                <GroupBox FontSize="16" Header="Sorting options">
                    <StackPanel Orientation="Vertical" Margin="5" IsEnabled="{Binding Path=IsSorting, Converter={StaticResource InverseBooleanConverter}}">
                        <StackPanel.Resources>
                            <Style TargetType="{x:Type RadioButton}">
                                <Setter Property="FontSize" Value="14"></Setter>
                                <Setter Property="Margin" Value="0 5 0 0"></Setter>
                            </Style>
                            
                        </StackPanel.Resources>
                        <RadioButton GroupName="Sorting" IsChecked="{Binding Path=SortingOption, 
                                                    Converter={StaticResource enumConverter},
                                                    ConverterParameter=Frequency}" Content="Fequency"></RadioButton>
                        <RadioButton GroupName="Sorting" IsChecked="{Binding Path=SortingOption, 
                                                    Converter={StaticResource enumConverter}, 
                                                    ConverterParameter=WordStart}" Content="Alphabetically"></RadioButton>
                        <RadioButton GroupName="Sorting" IsChecked="{Binding Path=SortingOption, 
                                                    Converter={StaticResource enumConverter}, 
                                                    ConverterParameter=WordEnd}" Content="Reverse"></RadioButton>
                    </StackPanel>
                </GroupBox>
                <Button Margin="50 10" Content="Export to CSV" IsEnabled="{Binding CanExport}" Click="ExportCSVCommand_Click"></Button>
            </StackPanel>
        </Border>
        <ListView FontSize="13" DockPanel.Dock="Right" ItemsSource="{Binding Words}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <ListView.View>
                <GridView>
                    <GridViewColumn DisplayMemberBinding="{Binding Rank}" Width="60">Rank</GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding Freq}" Width="60">Freq</GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding Content}" Width="120">Word</GridViewColumn>
                    <GridViewColumn DisplayMemberBinding="{Binding LemmaForms}" Width="150">Lemma word forms</GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </DockPanel>
</UserControl>
